/* ai-assistant.css */
/* 基础样式重置与变量定义 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #3b82f6;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #f1f5f9;
    --border-color: #e2e8f0;
    --message-user: #e0f2fe;
    --message-ai: #f1f5f9;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 8px;
}

/* 主容器样式 */
.ai-assistant-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
}

/* 侧边栏样式 */
.sidebar {
    width: 300px;
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.logo img {
    height: 32px;
    width: 32px;
    border-radius: 6px;
}

.logo span {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--secondary-color);
}

.chat-history {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.chat-item {
    padding: 0.75rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.chat-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.chat-item.active {
    background-color: rgba(37, 99, 235, 0.2);
    border-left: 3px solid var(--primary-color);
}

.chat-item i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chat-item .truncate {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.chat-item .time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.username {
    font-weight: 500;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-profile i {
    margin-left: auto;
    color: var(--text-secondary);
    cursor: pointer;
}

/* 主聊天区域样式 */
.main-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}

.chat-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-info h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/*.status-indicator {*/
/*    width: 10px;*/
/*    height: 10px;*/
/*    border-radius: 50%;*/
/*    background: var(--success-color);*/
/*    box-shadow: 0 0 10px var(--success-color);*/
/*    animation: pulse 2s infinite;*/
/*}*/
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 70%;
    background-color: var(--success-color);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.chat-messages {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.welcome-message {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.welcome-content {
    max-width: 800px;
    text-align: center;
}

.welcome-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.quick-questions {
    margin-top: 2rem;
    text-align: left;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.question-card {
    background-color: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.question-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.question-card i {
    color: var(--primary-color);
    font-size: 1.25rem;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 1130px;
    margin: 0 auto;
    width: 100%;
}

.user-message {
    flex-direction: row-reverse;
}

.avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 50px);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    align-items: center;
}

.sender-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.content {
    padding: 1rem;
    border-radius: var(--radius);
    line-height: 1.6;
}

.user-message .content {
    background-color: var(--message-user);
}

.ai-message .content {
    background-color: var(--message-ai);
    border: 1px solid var(--border-color);
}

.markdown-content {
    color: var(--text-primary);
}

.markdown-content p {
    margin-bottom: 1rem;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
}

.markdown-content code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.markdown-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
}

.typing-indicator {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 文件预览样式 */
.file-previews {
    margin-top: 1rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 1rem;
}

.file-preview {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

.file-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-info i {
    color: var(--text-secondary);
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn.small {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
}

.action-btn.danger:hover {
    color: var(--danger-color);
}

/* AI消息操作按钮 */
.ai-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: flex-end;
}

/* 聊天输入区域 */
.chat-input-area {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color);
    background-color: white;
}

.attached-files {
    margin-bottom: 1rem;
}

.attached-files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.attached-file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    max-width: 100%;
}

.attached-file-item.has-error {
    border-color: var(--danger-color);
}

.uploading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-error {
    color: var(--danger-color);
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.file-error-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    background-color: var(--danger-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    margin-bottom: 0.25rem;
    z-index: 10;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.remove-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--danger-color);
}

.input-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.file-upload-btn {
    position: relative;
}

.input-container {
    display: flex;
    gap: 0.75rem;
    position: relative;
}

textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 60px;
    max-height: 200px;
    resize: none;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.send-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
}

.send-btn:hover:not(:disabled) {
    background-color: var(--secondary-color);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ai-tips {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-tips i {
    color: #f59e0b;
}

.model-info {
    display: flex;
    gap: 1rem;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }

    .chat-messages {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .chat-header {
        padding: 1rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: 100%;
    }

    .question-grid {
        grid-template-columns: 1fr;
    }
}
/*模拟对战按钮*/
.flaw-section {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.flaw-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(45deg, #8ee546, #a6940b);
    color: white;
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s;
}

.flaw-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}
/* 攻击按钮 */

.attack-section {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.attack-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(45deg, #e546b3, #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s;
}

.attack-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

/* 在ai-assistant.css中添加 */
.defense-section {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.defense-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(45deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s;
}

.defense-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

/* 警告消息样式 */
.warning-message .content {
    border-left: 4px solid #ef4444;
    animation: pulseWarning 1.5s infinite;
}

@keyframes pulseWarning {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* 新增攻击面板样式 */
.attack-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.attack-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.attack-panel {
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(59, 130, 246, 0.3);
    padding: 30px;
    color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 攻击状态指示灯 */
.attack-status {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
}

/* 新增防御面板样式 */
.defense-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.defense-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.defense-panel {
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(59, 130, 246, 0.3);
    padding: 30px;
    color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 防御状态指示灯 */
.defense-status {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* 响应时间展示 */
.response-time {
    position: absolute;
    top: 60px;
    left: 20px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 1.1rem;
}

.response-time .highlight {
    color: #10b981;
    font-weight: bold;
    font-size: 1.3rem;
}

/* 防御流程容器 */
.defense-flow {
    display: flex;
    height: 100%;
    margin-top: 50px;
}
.defense-flow-container {
    display: flex;
    height: 100%;
    gap: 2rem;
}
/*.timeline-container {*/
/*    flex: 1;*/
/*    padding-right: 30px;*/
/*    border-right: 1px solid rgba(255, 255, 255, 0.1);*/
/*}*/

/*.visualization-container {*/
/*    flex: 1;*/
/*    padding-left: 30px;*/
/*}*/

.timeline-container,
.visualization-container {
    flex: 1;
    overflow: hidden;
}

/* 时间线动画增强 */
.timeline-item {
    opacity: 0.5;
    transform: translateX(-20px);
    transition: all 0.6s ease;
}

.timeline-item.active {
    opacity: 1;
    transform: translateX(0);
}

.timeline-icon {
    transition: all 0.4s ease;
}

.timeline-icon.active {
    background: #3b82f6;
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.3);
}

/* 攻击链可视化增强 */
.chain-diagram {
    position: relative;
    height: 200px;
    margin: 30px 0;
}

.chain-node {
    position: absolute;
    width: 100px;
    text-align: center;
    padding: 12px;
    background: linear-gradient(145deg, #1e40af, #3b82f6);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.5s ease;
    opacity: 0;
    transform: scale(0.8);
}

.chain-node.active {
    opacity: 1;
    transform: scale(1);
}

.chain-connector {
    position: absolute;
    height: 3px;
    background: linear-gradient(to right, #3b82f6, #10b981);
    opacity: 0;
    transition: opacity 0.8s ease;
}

.chain-connector.active {
    opacity: 1;
}

/* 策略可视化 */
.strategy-visual {
    margin-top: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    height: 250px;
    overflow: hidden;
    position: relative;
}

.strategy-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #93c5fd;
}

.strategy-content {
    display: flex;
    height: 100%;
}

.strategy-code {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 15px;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow: auto;
    color: #a5b4fc;
}

.strategy-code {
    max-height: 180px;
    overflow: auto;
}

.strategy-stats {
    width: 200px;
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #10b981;
    margin: 5px 0;
}

.stat-label {
    font-size: 0.85rem;
    color: #cbd5e1;
}
.response-time {
    top: 20px;
    left: 20px;
    padding: 8px 15px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: 8px;
    font-size: 1.1rem;
    z-index: 10;
}
/* 在 ai-assistant.css 中添加以下样式 */
.attack-chain h4 {
    margin-bottom: 15px;
    color: #93c5fd;
}

/* 确保图表容器有正确的高度 */
.chain-diagram {
    height: 200px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
}